

layui.use(['upload','form','layer'], function() {
    var $ = layui.jquery
        , upload = layui.upload;
    let form = layui.form;
    let layer = layui.layer


    form.on('submit(add)',function (data) {
        data = data.field;
        data.loginName=sessionStorage.getItem("loginName")
        $.ajax({
            url:'/back/nav/add',
            data:data,
            dataType:'json',
            type:'post',
            success:function (data) {
                console.log(data);
                if (data.result == "success") {
                    //发异步，把数据提交给php
                    layer.alert("增加成功", {
                            icon: 6
                        },
                        function () {
                            //关闭当前frame
                            xadmin.close();

                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                }
                if(data.result=="notLogin"){
                    window.open("/html/login.html", "_top");
                }
                else {
                    layer.alert("增加失败", {
                        icon: 1
                    });
                }
            }

        });
        return false;
    })


})



